//
//  AddViewController.m
//  map
//
//  Created by dllo on 16/4/25.
//  Copyright © 2016年 王彦森. All rights reserved.
//

#import "AddViewController.h"
#import "EaseMob.h"

@interface AddViewController ()
@property(nonatomic,strong)UITextField *userName;
@end

@implementation AddViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor yellowColor];
    
    self.userName = [[UITextField alloc]initWithFrame:CGRectMake(120, 50, 120, 40)];
    self.userName.layer.borderWidth = 1.5;
    self.userName.layer.cornerRadius = 15;
    [self.view addSubview:self.userName];
    
    UIButton * add = [UIButton buttonWithType:UIButtonTypeSystem];
    [add addTarget:self action:@selector(add:) forControlEvents:UIControlEventTouchUpInside];
    [add setTitle:@"添加" forState:UIControlStateNormal];
    add.frame = CGRectMake(120, 100, 50, 40);
    [self.view addSubview:add];
}

-(void)add:(UIButton*)button{

    NSString *message = [@"" stringByAppendingString:[[EaseMob sharedInstance].chatManager loginInfo][@"username"]];
    EMError *error = nil;
    
    [[EaseMob sharedInstance].chatManager addBuddy:self.userName.text message:message error:&error];
    if (error) {
        NSLog(@"添加好友有问题:%@",error);
    }else{
        NSLog(@"添加好友没有问题");
    }

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
